#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>

using namespace std;

class Solution
{
public:
    int ret, path, target;
    int findTargetSumWays(vector<int>& nums, int _target)
    {
        target = _target;
        dfs(nums, 0);
        return ret;
    }
    void dfs(vector<int>& nums, int pos)
    {
        if (nums.size() == pos)
        {
            if (path == target) ret++;
            return;
        }

        path += nums[pos];
        dfs(nums, pos + 1);
        path -= nums[pos];

        path -= nums[pos];
        dfs(nums, pos + 1);
        path += nums[pos];
    }
};